From 76f3c7dc8b7c78f5f73d1b6487fac5cc5f320ed4 Mon Sep 17 00:00:00 2001 From: Gilad Ben-Yossef Date: Tue, 14 May 2019 14:47:36 +0300 Subject: [PATCH] cryptocell: add product version awareness support Add support for multiple Cryptocell revisions which use different APIs. This commit only refactors the existing code in preperation to the addition of another Cryptocell revisions later on. Signed-off-by: Gilad Ben-Yossef Change-Id: I16d80b31afb6edd56dc645fee5ea619cc74f09b6 --- .../cryptocell/{ => 712}/cryptocell_crypto.c | 14 +++++++------- .../{ => 712}/cryptocell_plat_helpers.c | 6 +++--- drivers/auth/cryptocell/cryptocell_crypto.mk | 17 +++++++++++++---- .../cryptocell/{ => 712}/cc_crypto_boot_defs.h | 0 .../arm/cryptocell/{ => 712}/cc_pal_sb_plat.h | 0 .../arm/cryptocell/{ => 712}/cc_pal_types.h | 0 .../cryptocell/{ => 712}/cc_pal_types_plat.h | 0 .../arm/cryptocell/{ => 712}/cc_sec_defs.h | 0 .../arm/cryptocell/{ => 712}/crypto_driver.h | 0 include/drivers/arm/cryptocell/{ => 712}/nvm.h | 0 .../drivers/arm/cryptocell/{ => 712}/nvm_otp.h | 0 include/drivers/arm/cryptocell/{ => 712}/rsa.h | 0 .../arm/cryptocell/{ => 712}/sbrom_bsv_api.h | 0 .../cryptocell/{ => 712}/secureboot_base_func.h | 0 .../cryptocell/{ => 712}/secureboot_gen_defs.h | 0 include/drivers/arm/cryptocell/{ => 712}/util.h | 0 16 files changed, 23 insertions(+), 14 deletions(-) rename drivers/auth/cryptocell/{ => 712}/cryptocell_crypto.c (95%) rename drivers/auth/cryptocell/{ => 712}/cryptocell_plat_helpers.c (95%) rename include/drivers/arm/cryptocell/{ => 712}/cc_crypto_boot_defs.h (100%) rename include/drivers/arm/cryptocell/{ => 712}/cc_pal_sb_plat.h (100%) rename include/drivers/arm/cryptocell/{ => 712}/cc_pal_types.h (100%) rename include/drivers/arm/cryptocell/{ => 712}/cc_pal_types_plat.h (100%) rename include/drivers/arm/cryptocell/{ => 712}/cc_sec_defs.h (100%) rename include/drivers/arm/cryptocell/{ => 712}/crypto_driver.h (100%) rename include/drivers/arm/cryptocell/{ => 712}/nvm.h (100%) rename include/drivers/arm/cryptocell/{ => 712}/nvm_otp.h (100%) rename include/drivers/arm/cryptocell/{ => 712}/rsa.h (100%) rename include/drivers/arm/cryptocell/{ => 712}/sbrom_bsv_api.h (100%) rename include/drivers/arm/cryptocell/{ => 712}/secureboot_base_func.h (100%) rename include/drivers/arm/cryptocell/{ => 712}/secureboot_gen_defs.h (100%) rename include/drivers/arm/cryptocell/{ => 712}/util.h (100%) diff --git a/drivers/auth/cryptocell/cryptocell_crypto.c b/drivers/auth/cryptocell/712/cryptocell_crypto.c similarity index 95% rename from drivers/auth/cryptocell/cryptocell_crypto.c rename to drivers/auth/cryptocell/712/cryptocell_crypto.c index 6bf27a95..395c5508 100644 --- a/drivers/auth/cryptocell/cryptocell_crypto.c +++ b/drivers/auth/cryptocell/712/cryptocell_crypto.c @@ -11,19 +11,19 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include #include -#define LIB_NAME "CryptoCell SBROM" +#define LIB_NAME "CryptoCell 712 SBROM" #define RSA_SALT_LEN 32 #define RSA_EXPONENT 65537 diff --git a/drivers/auth/cryptocell/cryptocell_plat_helpers.c b/drivers/auth/cryptocell/712/cryptocell_plat_helpers.c similarity index 95% rename from drivers/auth/cryptocell/cryptocell_plat_helpers.c rename to drivers/auth/cryptocell/712/cryptocell_plat_helpers.c index 1bd9c6bc..53d77dbe 100644 --- a/drivers/auth/cryptocell/cryptocell_plat_helpers.c +++ b/drivers/auth/cryptocell/712/cryptocell_plat_helpers.c @@ -14,9 +14,9 @@ #include #include -#include -#include -#include +#include +#include +#include /* * Return the ROTPK hash diff --git a/drivers/auth/cryptocell/cryptocell_crypto.mk b/drivers/auth/cryptocell/cryptocell_crypto.mk index 27c1e852..d42a2e7e 100644 --- a/drivers/auth/cryptocell/cryptocell_crypto.mk +++ b/drivers/auth/cryptocell/cryptocell_crypto.mk @@ -17,11 +17,20 @@ ifeq (${CCSBROM_LIB_PATH},) $(error Error: CCSBROM_LIB_PATH not set) endif -TF_LDFLAGS += -L$(CCSBROM_LIB_PATH) -LDLIBS += -lcc_712sbromx509 +CRYPTOCELL_VERSION ?= 712 +ifeq (${CRYPTOCELL_VERSION},712) + CCSBROM_LIB_FILENAME := cc_712sbromx509 +else + $(error Error: CRYPTOCELL_VERSION set to invalid version) +endif + +CRYPTOCELL_SRC_DIR := drivers/auth/cryptocell/${CRYPTOCELL_VERSION}/ -CRYPTOCELL_SOURCES := drivers/auth/cryptocell/cryptocell_crypto.c \ - drivers/auth/cryptocell/cryptocell_plat_helpers.c +CRYPTOCELL_SOURCES := ${CRYPTOCELL_SRC_DIR}/cryptocell_crypto.c \ + ${CRYPTOCELL_SRC_DIR}/cryptocell_plat_helpers.c + +TF_LDFLAGS += -L$(CCSBROM_LIB_PATH) +LDLIBS += -l$(CCSBROM_LIB_FILENAME) BL1_SOURCES += ${CRYPTOCELL_SOURCES} BL2_SOURCES += ${CRYPTOCELL_SOURCES} diff --git a/include/drivers/arm/cryptocell/cc_crypto_boot_defs.h b/include/drivers/arm/cryptocell/712/cc_crypto_boot_defs.h similarity index 100% rename from include/drivers/arm/cryptocell/cc_crypto_boot_defs.h rename to include/drivers/arm/cryptocell/712/cc_crypto_boot_defs.h diff --git a/include/drivers/arm/cryptocell/cc_pal_sb_plat.h b/include/drivers/arm/cryptocell/712/cc_pal_sb_plat.h similarity index 100% rename from include/drivers/arm/cryptocell/cc_pal_sb_plat.h rename to include/drivers/arm/cryptocell/712/cc_pal_sb_plat.h diff --git a/include/drivers/arm/cryptocell/cc_pal_types.h b/include/drivers/arm/cryptocell/712/cc_pal_types.h similarity index 100% rename from include/drivers/arm/cryptocell/cc_pal_types.h rename to include/drivers/arm/cryptocell/712/cc_pal_types.h diff --git a/include/drivers/arm/cryptocell/cc_pal_types_plat.h b/include/drivers/arm/cryptocell/712/cc_pal_types_plat.h similarity index 100% rename from include/drivers/arm/cryptocell/cc_pal_types_plat.h rename to include/drivers/arm/cryptocell/712/cc_pal_types_plat.h diff --git a/include/drivers/arm/cryptocell/cc_sec_defs.h b/include/drivers/arm/cryptocell/712/cc_sec_defs.h similarity index 100% rename from include/drivers/arm/cryptocell/cc_sec_defs.h rename to include/drivers/arm/cryptocell/712/cc_sec_defs.h diff --git a/include/drivers/arm/cryptocell/crypto_driver.h b/include/drivers/arm/cryptocell/712/crypto_driver.h similarity index 100% rename from include/drivers/arm/cryptocell/crypto_driver.h rename to include/drivers/arm/cryptocell/712/crypto_driver.h diff --git a/include/drivers/arm/cryptocell/nvm.h b/include/drivers/arm/cryptocell/712/nvm.h similarity index 100% rename from include/drivers/arm/cryptocell/nvm.h rename to include/drivers/arm/cryptocell/712/nvm.h diff --git a/include/drivers/arm/cryptocell/nvm_otp.h b/include/drivers/arm/cryptocell/712/nvm_otp.h similarity index 100% rename from include/drivers/arm/cryptocell/nvm_otp.h rename to include/drivers/arm/cryptocell/712/nvm_otp.h diff --git a/include/drivers/arm/cryptocell/rsa.h b/include/drivers/arm/cryptocell/712/rsa.h similarity index 100% rename from include/drivers/arm/cryptocell/rsa.h rename to include/drivers/arm/cryptocell/712/rsa.h diff --git a/include/drivers/arm/cryptocell/sbrom_bsv_api.h b/include/drivers/arm/cryptocell/712/sbrom_bsv_api.h similarity index 100% rename from include/drivers/arm/cryptocell/sbrom_bsv_api.h rename to include/drivers/arm/cryptocell/712/sbrom_bsv_api.h diff --git a/include/drivers/arm/cryptocell/secureboot_base_func.h b/include/drivers/arm/cryptocell/712/secureboot_base_func.h similarity index 100% rename from include/drivers/arm/cryptocell/secureboot_base_func.h rename to include/drivers/arm/cryptocell/712/secureboot_base_func.h diff --git a/include/drivers/arm/cryptocell/secureboot_gen_defs.h b/include/drivers/arm/cryptocell/712/secureboot_gen_defs.h similarity index 100% rename from include/drivers/arm/cryptocell/secureboot_gen_defs.h rename to include/drivers/arm/cryptocell/712/secureboot_gen_defs.h diff --git a/include/drivers/arm/cryptocell/util.h b/include/drivers/arm/cryptocell/712/util.h similarity index 100% rename from include/drivers/arm/cryptocell/util.h rename to include/drivers/arm/cryptocell/712/util.h -- 2.30.2